Page({

  /**
   * 页面的初始数据
   */
  data: {
    xlb_key: 'QCIC82jD9e6JLK0OZcJW1mOB7C5v7QiR1537447029',
    activity_list: [],
    lunbo_list: [],
    canIUse: wx.canIUse('button.open-type.getUserInfo')
  },
  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.initLunboList();
    this.initActivityList();
  },

  /**
   * 初始化活动列表
   */
  initActivityList () {
    let _this = this;
    let xlb_key = _this.data.xlb_key;
    wx.request({
      url: 'https://mini.xiaoliebian.com/api/mini/mini_get_activity_list',
      data: {
        xlb_key
      },
      success (res) {
        if (parseInt(res.data.code, 10) == 200) {
          _this.setData({
            activity_list: res.data.list
          })
        }
      }
    })
  },

  /**
   * 初始化轮播
   */
  initLunboList () {
    let _this = this;
    let xlb_key = _this.data.xlb_key;
    wx.request({
      url: 'https://mini.xiaoliebian.com/api/mini/mini_get_lunbo_list',
      data: {
        xlb_key
      },
      success(res) {
        if (parseInt(res.data.code, 10) == 200) {
          _this.setData({
            lunbo_list: res.data.list
          })
        }
      }
    })
  },

  /**
   * 第一次授权登陆
   */
  bindGetUserInfo: function (e) {
    let eventkey = e.target.dataset.eventkey;
    wx.navigateTo({
      url: '../xlb_plug/plug?eventkey=' + eventkey
    })
  },

  onPullDownRefresh: function () {
    this.initLunboList();
    this.initActivityList();
    setTimeout(function () {
      wx.stopPullDownRefresh()
    }, 2000)
  },

  onShareAppMessage: function () {
    
  }
})